import xlrd
filename = "/Users/wangshuguan/Downloads/通讯录导入模板-联系人.xls"
filename2 = "/Users/wangshuguan/Downloads/伊川县通讯录通讯录联系人20191126185816.xls"
# col = 2
for col in range(8):
    #新数据
    startRow = 1
    data = xlrd.open_workbook(filename)
    table = data.sheets()[0]
    values = table.col_values(col, start_rowx=startRow, end_rowx=None)
    
    #原始数据
    startRow2 = 1
    data2 = xlrd.open_workbook(filename2)
    table2 = data2.sheets()[0]
    values2 = table2.col_values(col, start_rowx=startRow2, end_rowx=None)
    
    nvalues =  len(values)
    nvalues2 = len(values2)
    print(f"count:{nvalues}-{nvalues2},col:{col}")
    if nvalues2 == nvalues:
        for i in range(nvalues):
    #         left = "0379"+str(int(values[i]))
            left = values[i]
            if col == 2:
                left = str(int(values[i]))
            elif col == 3 or col == 4:
                if type(values[i]) == type(""):
                    if values[i].find("0379")==-1 and len(values[i]) > 0 and len(values[i]) != 11:
                        left = "0379"+values[i]
                else:
                    if len(f"{int(values[i])}") != 11:
                        left = f"0379{int(values[i])}"
                    else:
                        left = f"{int(values[i])}"
            elif col == 5 :
                if type(values[i]) == type(1.1):
                    left = f"{int(values[i])}"
                    
            left = left.replace("-", "")
            right = values2[i]
            if left != right:
                print(f"{i+startRow2+1}原始数据：{table2.cell_value(i+1,0)}-{right},需要改为：{left}")
        print("检查完毕")
    else:
        print("count error")